<?php

use yii\db\Migration;

class m210915_111731_minerva_tasks extends Migration
{
    public function up()
    {
        /* 取消外键约束 */
        $this->execute('SET foreign_key_checks = 0');
        
        /* 创建表 */
        $this->createTable('{{%minerva_tasks}}', [
            'id' => "int(11) NOT NULL AUTO_INCREMENT",
            'one_department' => "int(11) NULL COMMENT '一级部门'",
            'two_department' => "int(11) NULL COMMENT '二级部门'",
            'task_id' => "char(64) NULL COMMENT '任务id'",
            'task_title' => "char(128) NULL COMMENT '任务名称'",
            'task_level' => "tinyint(11) NULL DEFAULT '0' COMMENT '任务等级1普通2.优先3.紧急'",
            'file_nums' => "int(11) NULL DEFAULT '0' COMMENT '文件数量'",
            'file_sizes' => "bigint(20) NULL DEFAULT '0' COMMENT '文件大小'",
            'ftp' => "char(80) NULL COMMENT 'ftp服务器主键'",
            'status' => "int(11) NULL DEFAULT '0' COMMENT '任务状态'",
            'user_id' => "int(11) NULL DEFAULT '0' COMMENT '操作着主键id'",
            'check_user_id' => "int(11) NULL DEFAULT '0' COMMENT '审核者主键id'",
            'create_at' => "timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间'",
            'check_time' => "timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '审核时间'",
            'over_time' => "timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '结束时间'",
            'is_deleted' => "tinyint(1) NULL DEFAULT '0' COMMENT '删除(1删除,0未删)'",
            'client_type' => "char(4) NULL DEFAULT ''",
            'client_ip' => "char(32) NULL",
            'dest_net_name' => "varchar(255) NULL",
            'createTaskXML' => "varchar(255) NULL",
            'PRIMARY KEY (`id`)'
        ], "ENGINE=InnoDB  DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='大数据系统-任务表'");
        
        /* 索引设置 */
        $this->createIndex('idx_mine_tasks_client_type','{{%minerva_tasks}}','client_type',0);
        
        
        /* 表数据 */
        $this->insert('{{%minerva_tasks}}',['id'=>'36','one_department'=>'1','two_department'=>'2','task_id'=>NULL,'task_title'=>'测试任务444','task_level'=>'1','file_nums'=>'8','file_sizes'=>'6','ftp'=>NULL,'status'=>'0','user_id'=>'0','check_user_id'=>'0','create_at'=>'2021-01-28 17:47:13','check_time'=>'2021-01-28 17:47:13','over_time'=>'2021-01-28 17:47:13','is_deleted'=>'0','client_type'=>'web','client_ip'=>'172.16.0.118','dest_net_name'=>NULL,'createTaskXML'=>NULL]);
        $this->insert('{{%minerva_tasks}}',['id'=>'37','one_department'=>'1','two_department'=>'2','task_id'=>NULL,'task_title'=>'测试任务444','task_level'=>'1','file_nums'=>'8','file_sizes'=>'4','ftp'=>NULL,'status'=>'0','user_id'=>'0','check_user_id'=>'0','create_at'=>'2021-01-28 17:58:03','check_time'=>'2021-01-28 17:58:03','over_time'=>'2021-01-28 17:58:03','is_deleted'=>'0','client_type'=>'web','client_ip'=>'172.16.0.118','dest_net_name'=>NULL,'createTaskXML'=>NULL]);
        $this->insert('{{%minerva_tasks}}',['id'=>'38','one_department'=>'1','two_department'=>'2','task_id'=>NULL,'task_title'=>'测试任务444','task_level'=>'1','file_nums'=>'8','file_sizes'=>'9','ftp'=>NULL,'status'=>'0','user_id'=>'0','check_user_id'=>'0','create_at'=>'2021-01-28 17:59:10','check_time'=>'2021-01-28 17:59:10','over_time'=>'2021-01-28 17:59:10','is_deleted'=>'0','client_type'=>'pc','client_ip'=>'172.16.0.118','dest_net_name'=>NULL,'createTaskXML'=>NULL]);
        
        /* 设置外键约束 */
        $this->execute('SET foreign_key_checks = 1;');
    }

    public function down()
    {
        $this->execute('SET foreign_key_checks = 0');
        /* 删除表 */
        $this->dropTable('{{%minerva_tasks}}');
        $this->execute('SET foreign_key_checks = 1;');
    }
}

